package 笔试.OPPO;

import java.util.Scanner;

public class 有限次交换数组 {
    public static boolean flag;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        while (T-- > 0) {
            int n = in.nextInt();
            int[] nums = new int[n];
            flag = true;
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
                if (i > 0 && nums[i - 1] > nums[i]) {
                    flag = false;
                }
            }
            if (n >= 2 && nums[n - 2] > nums[n - 1]) {
                flag = false;
            }
            boolean result = solve(nums);
            if (result) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

    private static boolean solve(int[] nums) {
        if (flag) {
            return true;
        }
//        System.out.println(Arrays.toString(nums));
        for (int i = 0; i < nums.length; i += 2) {
            boolean swaped = false;
            for (int j = 0; j < nums.length - 2 - i; j += 2) {
                if (nums[j] > nums[j + 2]) {
                    swap(nums, j, j + 2);
                    swaped = true;
                }
            }
            if (!swaped) {
                break;
            }
        }
//        System.out.println(Arrays.toString(nums));
        for (int i = 1; i < nums.length; i += 2) {
            boolean swaped = false;
            for (int j = 1; j <= nums.length - 2 - i; j += 2) {
                if (nums[j] > nums[j + 2]) {
                    swap(nums, j, j + 2);
                    swaped = true;
                }
            }
            if (!swaped) {
                break;
            }
        }
//        System.out.println(Arrays.toString(nums));
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i] > nums[i + 1]) {
                return false;
            }
        }
        return true;
    }

    private static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

}